package com.colbby.datahouse.lock;

import java.util.concurrent.TimeUnit;

/**
 * 根据一个对象锁定
 * @author liujingyu
 * @Date 2013-10-12
 *
 */
public interface Lock<T> {

	public void lock(T t);
	
	public void unlock(T t);

	/**
	 * 尝试锁住
	 * @return
	 */
	public boolean tryLock(T t);

	/**
	 * 尝试在规定时间内锁住
	 * @param time
	 * @param timeUnit
	 * @return
	 */
	public boolean tryLock(T t, long time, TimeUnit timeUnit) throws InterruptedException;
}
